
define(function(require, exports, module) {
    var $=require('zepto');
    api=require('api');
    sw=require('swiper');
    cn=require('conment');
    lg=require('login');
    pop=require('popup');
    textSlider=require('textSlider');
    module.exports = {
        swiper:function () {
            var swiper = new Swiper('.banner-container', {
                autoplay: {
                    // delay: 3000,//1秒切换一次
                },
                pagination: {
                    el: '.swiper-pagination',
                },
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                    hideOnClick: true,
                    hiddenClass: 'my-button-hidden',
                },
                on: {
                    slideChangeTransitionEnd: function(){
                        if(this.isEnd){
                            this.navigation.$nextEl.css('display','none');
                        }else{
                            this.navigation.$nextEl.css('display','block');
                        }
                    },
                },
            });
            swiper.el.onmouseover=function(){
                swiper.navigation.$nextEl.removeClass('hide');
                swiper.navigation.$prevEl.removeClass('hide');
            };
            swiper.el.onmouseout=function(){
                swiper.navigation.$nextEl.addClass('hide');
                swiper.navigation.$prevEl.addClass('hide');
            };

        },

        home_int:{
            _page:'1',
            _length:"10",
            _type:'1',
            _style:'10',

            _type2:'2',
            _style2:'20',
        },
        newsflash:function () {
            var _this=this;
            cn.Ajax(api.homelist,{
                page:_this.home_int._page,
                length:_this.home_int._length,
                type:_this.home_int._type,
                style:_this.home_int._style,
            },function(d){
                var water=new Array();
                var list=d.list;
                $('#jiaoyidongtai1').html('');
                $.each(list,function(i,l,array){
                    water.push(' <li class="clearfix"> <span>'+l.nickname+'</span> <span>'+l.amount+'</span> <span>'+l.name+l.code+'</span> <a href="/comview/buy.html?code='+l.code+'" class="goToBuyNow">立即点买</a> </li>')
                });
                $('#jiaoyidongtai1').html(water.join(''));

            },'post')
        },
        profitflash:function () {
            var _this=this;
            cn.Ajax(api.homelist,{
                page:_this.home_int._page,
                length:_this.home_int._length,
                type:_this.home_int._type2,
                style:_this.home_int._style2,
            },function(d){
                var water=new Array();
                var list=d.list;
                if(list.length>0){
                    $('#earningList1').html('');
                    $.each(list,function(i,l,array){
                        water.push('<li class="clearfix"> <span>'+(i>=3?'<i>'+(i+1)+'</i>':'<img src="./img/home/rank'+(i+1)+'.png">')+'</span> <span>'+l.nickname+'</span> <span>累计盈利'+l.amountDifference+'元</span> <a href="/comview/buy.html?code='+l.code+'">A股点买</a> </li>')
                    });
                    $('#earningList1').html(water.join(''));
                }
            },'post')
        },
        init:function(){
            var _this=this;
            _this.swiper();
            lg.userInfo();
            _this.newsflash();
            _this.profitflash();
            $('#login-btn').on('click',function () {
                var t=$.trim($("#userTel").val()),p=$.trim($("#userPwd").val());
                lg.login(t,p)
            });
            $(".der").textSlider({
                    line:1,
                    speed:500,
                    timer:3000
                }
            );
        },

    }
});